<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>@yield('title')</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <script type="text/javascript" src="{{asset('manger/plugins/layui2.0/layui.js')}}"></script>
    <link rel="stylesheet" href="{{asset('manger/plugins/layui2.0/css/layui.css')}}" media="all" />
    <link rel="stylesheet" href="{{asset('manger/plugins/font-awesome/css/font-awesome.min.css')}}">
</head>

<body>
<div style="margin: 15px;">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>@yield('barName')</legend>
    </fieldset>
</div>
<blockquote class="layui-elem-quote">
    <button type="button" class="layui-btn layui-btn-small" id="getAll"><i class="fa fa-plus" aria-hidden="true"></i> 添加</button>
    <form class="layui-form" style="float:right;">
        <div class="layui-inline">
        <input type="text" class="layui-input" width="200px" id="datetime" name="searchTime" value="{{$searchTime or ''}}" placeholder="日期范围搜索">
        </div>
        <div class="layui-inline">
                <input type="text" name="searchKey" placeholder="关键字查询" autocomplete="off" value="{{$searchKey or ''}}" class="layui-input">
        </div>
                <button lay-filter="search" class="layui-btn" lay-submit><i class="fa fa-search" aria-hidden="true"></i> 查询</button>
    </form>

</blockquote>


<table id="table"></table>
<script type="text/html" id="toolbar">
    <a class="layui-btn layui-btn-mini" lay-event="detail">查看</a>
    <a class="layui-btn layui-btn-mini" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="del">删除</a>
</script>
<script>
    layui.use(['table','jquery'], function(){
        var table = layui.table;
         var $=layui.jquery;
        table.render({
            elem:"#table",
            page:true,
            url:'{{route('admin.user.ajaxList')}}',
            where:{searchKey:$("input[name='searchKey']").val(),searchTime:$("input[name='searchTime']").val()},
            height:440,
            cols:  [[ //标题栏
                {field: 'id', title: 'ID', width: 80}
                ,{field: 'name', title: '用户名', width: 250},
                {field: 'email', title: '邮箱', width: 250},
                {field: 'created_at', title: '创建时间', width: 250},
                {fixed: 'right', width:250,title:'操作', align:'center', toolbar: '#toolbar'}
                //这里的toolbar值是模板元素的选择器
            ]],

            response: {//返回格式自定义
                statusName: 'code' //数据状态的字段名称，默认：code
                ,statusCode: 0 //成功的状态码，默认：0
                ,msgName: 'msg' //状态信息的字段名称，默认：msg
                ,countName: 'total' //数据总数的字段名称，默认：count
                ,dataName: 'data' //数据列表的字段名称，默认：data
            }
        });
    });
    //时间日期
    layui.use('laydate',function(){
        var laydate=layui.laydate;
        laydate.render({
            elem: '#datetime'
            ,type: 'datetime'
            ,range: '~'
        });
    });
    layui.use('layer', function(){
        var layer = layui.layer;
        //验证错误
        @if (count($errors) > 0)
            @foreach ($errors->all() as $error)
            layer.msg('{{$error}}', {icon: 5},function () {

        });
        @endforeach

    });
    @endif
    //返回成功信息
    @if(session('info'))
        @if(session('info')=='success')
           layer.msg('{{session('msg')}}',{icon:1});
    @else
          layer.msg('{{session('msg')}}',{icon:5});
    @endif
    @endif
    })

</script>
</body>

</html>